package com.seu.me.test;

import org.apache.commons.lang.time.DateUtils;
import org.joda.time.DateTime;

import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;

/**
 * @author liangfeihu
 * @since 2019/6/4
 */
public class MyTest9 {

    public static void main(String[] args) {
        Set<Integer> intSet = new HashSet<>();
        for (int i = 0; i < 10; i++) {
            intSet.add(i);
        }
        intSet.forEach(System.out::print);
        System.out.println("");

        DateTime time = new DateTime(new Date());
        System.out.println(time.toString("yyyy-MM-dd HH:mm:ss"));
        String hm = time.toString("yyyy-MM-dd HH:mm");
        System.out.println(hm);
        String str = hm + ":00";

        // 不支持
        //DateTime time2 = new DateTime(hm + ":00");
        //System.out.println(time2.toString("yyyy-MM-dd HH:mm:ss"));

        String[] strings = new DateTime(System.currentTimeMillis()).toString("yyyy-MM-dd").split("-");
        Stream.of(strings).forEach(System.out::println);

        String[] strings2 = new DateTime(DateUtils.addDays(new Date(), -1)).toString("yyyy-MM-dd").split("-");
        Stream.of(strings2).forEach(System.out::println);

        Date truncate = org.apache.commons.lang3.time.DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH);
        String truncateStr = new DateTime(truncate).toString("yyyy-MM-dd HH:mm:ss");
        System.out.println(truncateStr);

    }

}
